﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
//Thu Vien Them Vao
using QuanLyQuanCafe.BusinessLogic;
using QuanLyQuanCafe.BusinessObject;

namespace QuanLyQuanCafe
{
    public partial class FrmTraCuuMonAn : Form
    {
        MonAnBL monanBL = new MonAnBL();
        public FrmTraCuuMonAn()
        {
            InitializeComponent();
        }

        private void FrmTraCuuMonAn_Load(object sender, EventArgs e)
        {
            dataGridViewMonAn.DataSource = monanBL.LayDanhSachTraCuuMonAn();
            for (int i = 0; i < dataGridViewMonAn.Rows.Count - 1; i++)
            {
                dataGridViewMonAn.Rows[i].Cells["colSTT"].Value = i + 1;
            } 
        }

        private void txtMonAn_TextChanged(object sender, EventArgs e)
        {
            string tenMA = txtMonAn.Text;
            string giathuongMA = txtGia.Text;
            string tennhomMA = txtNhomMon.Text;
            dataGridViewMonAn.DataSource = monanBL.LayKetQuaDanhSachTraCuuMonAn(tenMA, giathuongMA, tennhomMA);
            for (int i = 0; i < dataGridViewMonAn.Rows.Count - 1; i++)
            {
                dataGridViewMonAn.Rows[i].Cells["colSTT"].Value = i + 1;
            } 
        }

        private void txtNhomMon_TextChanged(object sender, EventArgs e)
        {
            string tenMA = txtMonAn.Text;
            string giathuongMA = txtGia.Text;
            string tennhomMA = txtNhomMon.Text;
            dataGridViewMonAn.DataSource = monanBL.LayKetQuaDanhSachTraCuuMonAn(tenMA, giathuongMA, tennhomMA);
            for (int i = 0; i < dataGridViewMonAn.Rows.Count - 1; i++)
            {
                dataGridViewMonAn.Rows[i].Cells["colSTT"].Value = i + 1;
            }
        }

        private void txtGia_TextChanged(object sender, EventArgs e)
        {
            string tenMA = txtMonAn.Text;
            string giathuongMA = txtGia.Text;
            string tennhomMA = txtNhomMon.Text;
            dataGridViewMonAn.DataSource = monanBL.LayKetQuaDanhSachTraCuuMonAn(tenMA, giathuongMA, tennhomMA);
            for (int i = 0; i < dataGridViewMonAn.Rows.Count - 1; i++)
            {
                dataGridViewMonAn.Rows[i].Cells["colSTT"].Value = i + 1;
            }
        }

        private void btnHuyTraCuu_Click(object sender, EventArgs e)
        {
            txtMonAn.Text = "";
            txtNhomMon.Text = "";
            txtGia.Text = "";
        }
    }
}
